import React, { useState, useEffect } from 'react';
import ReactDOM from 'react-dom';
import { Link, useHistory } from 'react-router-dom'
import { Layout, Menu, Breadcrumb, Row, Col, Button, Tabs, Space, message } from 'antd';
import { UserOutlined, LaptopOutlined, NotificationOutlined } from '@ant-design/icons';
import { checkAdmin } from '../../utils/loginUtils/loginMethod'
import axios from 'axios'
import api from '../../utils/requestUtils/apiConfig'
import QuestionManagement from './questionManagement/index'
import UserManageMent from './userManage/index'
import ScoreManage from './scoreManage/index'
export default () => {
    const { TabPane } = Tabs;
    const [coachInfoList, setCoachInfoList] = useState([])
    const [coachInfo, setCoachInfo] = useState()

    const queryAllCoach = () => {
        axios({
            url: api.queryAllCoach,
            method: 'get',
            headers: '',
            params: {},
        }).then((res) => {
            const result = res.data.data
            const coachDataSource = []
            const coachInfo = new Map()
            result.forEach(item => {
                coachDataSource.push({
                    label: item.trueName,
                    value: item.id
                })
                coachInfo.set(item.id, item.trueName)
            })
            setCoachInfo(coachInfo)
            setCoachInfoList(coachDataSource)
        })
    }

    useEffect(() => {
        queryAllCoach()
    }, [])
    return (
        <>
            <Tabs
                size='large'
                tabPosition='left'
            >
                <TabPane tab="试题管理" key="1">
                    <QuestionManagement />
                </TabPane>
                <TabPane tab="用户管理" key="2">
                    <UserManageMent
                        coachInfoList={coachInfoList}
                        setCoachInfoList={setCoachInfoList}
                        coachInfo={coachInfo}
                    />
                </TabPane>
                <TabPane tab="成绩管理" key="3">
                    <ScoreManage/>
                </TabPane>
                <TabPane tab="数值统计" key="4">
                    Content of Tab 3
                </TabPane>
            </Tabs>
        </>
    )
}


